package com.report.service;

import java.util.Collection;
import java.util.Map;

import javax.ejb.Stateless;

import com.common.util.ObjectUtils;
import com.core.service.AppBaseService;   
import com.report.entity.*;

 
@Stateless
public class SVC_REPORT extends AppBaseService implements SVC_REPORTRemote, SVC_REPORTLocal { 

	@Override
	public Map ADD_BBDY(Map param) {
		TB_REPORT_BBDY tdo = ObjectUtils.mapToJavaBean(param, TB_REPORT_BBDY.class); 
		tdo.setID(tdo.uuid()); 
		tdo.setCREATE_TIME(getOpTime(param));
		tdo.setOP_ITEM(getOpTime(param));
		tdo.setOPID(getOpid(param));  
		getJpaDao().save(tdo); 
		
		Collection<Map> list_fz=ObjectUtils.getMapValue(param, "LIST_TB_REPORT_BBXDY", Collection.class);
		if(list_fz!=null){
			for(Map item :list_fz){
				TB_REPORT_BBXDY fz =  ObjectUtils.mapToJavaBean(item, TB_REPORT_BBXDY.class);
				fz.setID(fz.uuid());
				fz.setBBID(tdo.getID());
				fz.setCREATE_TIME(getOpTime(param));
				fz.setOP_ITEM(getOpTime(param));
				fz.setOPID(getOpid(param));
				getJpaDao().save(fz);
			}
		}  
		 
		return ObjectUtils.javaBeanToMap(tdo);
	}

	@Override
	public Map UPD_BBDY(Map param) {
		TB_REPORT_BBDY tdo = ObjectUtils.mapToJavaBean(param, TB_REPORT_BBDY.class);  
		tdo.setOP_ITEM(getOpTime(param));
		tdo.setOPID(getOpid(param)); 
		
		TB_REPORT_BBDY po = getJpaDao().find(TB_REPORT_BBDY.class,tdo.getID());   
		
		ObjectUtils.copyJavaBeanToBean(tdo, po, "CREATE_TIME" ); 
		getJpaDao().update(po);
		return ObjectUtils.javaBeanToMap(po);
	}

	@Override
	public void DEL_BBDY(Map param) {
		TB_REPORT_BBDY tdo = ObjectUtils.mapToJavaBean(param, TB_REPORT_BBDY.class); 
		getJpaDao().delete(TB_REPORT_BBDY.class,  tdo.getID());
	}

	@Override
	public Map ADD_BBXDY(Map param) {
		TB_REPORT_BBXDY tdo = ObjectUtils.mapToJavaBean(param, TB_REPORT_BBXDY.class); 
		tdo.setID(tdo.uuid()); 
		tdo.setCREATE_TIME(getOpTime(param));
		tdo.setOP_ITEM(getOpTime(param));
		tdo.setOPID(getOpid(param));  
		getJpaDao().save(tdo); 
		
		return ObjectUtils.javaBeanToMap(tdo);
	}

	@Override
	public Map UPD_BBXDY(Map param) {
		TB_REPORT_BBXDY tdo = ObjectUtils.mapToJavaBean(param, TB_REPORT_BBXDY.class);  
		tdo.setOP_ITEM(getOpTime(param));
		tdo.setOPID(getOpid(param)); 
		
		TB_REPORT_BBXDY po = getJpaDao().find(TB_REPORT_BBXDY.class,tdo.getID());   
		
		ObjectUtils.copyJavaBeanToBean(tdo, po, "CREATE_TIME" ); 
		getJpaDao().update(po);
		return ObjectUtils.javaBeanToMap(po);
	}

	@Override
	public void DEL_BBXDY(Map param) {
		TB_REPORT_BBXDY tdo = ObjectUtils.mapToJavaBean(param, TB_REPORT_BBXDY.class); 
		getJpaDao().delete(TB_REPORT_BBXDY.class,  tdo.getID());
	}

}
